package com.fenqing.leetcode.code.t0_200.t0_100;

import cn.hutool.core.util.ArrayUtil;
import com.fenqing.annotations.Execute;
import com.fenqing.core.Topic;

import java.util.Arrays;

/**
 * @author fenqing
 */
public class Topic027 extends Topic {
    /**
     * 构造器
     *
     * @param input1 输入
     * @param input2 输入
     */
    public Topic027(String input1, String input2) {
        super(input1, input2);
    }

    @Execute
    public int removeElement(int[] nums, int val) {
        int i = 0, j = 0;
        int length = nums.length;
        while (j < length) {
            int num = nums[j];
            if (num != val) {
                nums[i] = num;
                i++;
            }
            j++;
        }
        return i;
    }

    public static void main(String[] args) {
        Topic027 topic27 = new Topic027("[1,2,3]", "2");
        Integer run = topic27.run();
        int[] object11 = topic27.getObject(0);
        System.out.println(Arrays.toString(ArrayUtil.sub(object11, 0, run)));
        System.out.println(run);
    }
}
